<?php
/**
 * Factory for AutoPrimitiveValueConverter objects
 *
 * @author  Stephan Schmidt <schst@xjconf.net>
 * @package XJConf
 */
XJConfLoader::load('converters.factories.ValueConverterFactory',
                   'converters.AutoPrimitiveValueConverter');

/**
 * Factory for AutoPrimitiveValueConverter objects
 *
 * @package XJConf
 */
class AutoPrimitiveValueConverterFactory implements ValueConverterFactory {

    /**
     * This factory is only responsible, if the type
     * is set to "xjconf:auto-primitive"
     *
     * @param Definition $def
     * @return boolean
     */
    public function isResponsible(Definition $def) {
        return 'xjconf:auto-primitive' === $def->getType();
    }

    /**
     * Create a value converter
     *
     * @param Definition $def
     * @return ValueConverter
     */
    public function createValueConverter(Definition $def) {
        $converter = new AutoPrimitiveValueConverter();
        return $converter;
    }
}
?>